
const { Sequelize } = require('sequelize');
const {SQL_DATABASE,SQL_USERNAME,SQL_PASSWORD} =require('../config/getconfig.js');
const sequelize = new Sequelize(SQL_DATABASE, SQL_USERNAME, SQL_PASSWORD, {
    host: 'localhost',
    dialect: "mysql",
    port: 3306,
    timezone: "+08:00",
    dateString:true,
    define: {
      freezeTableName: true,
      
    }
});

(async()=>{
    try {
        await sequelize.authenticate();
        console.log('Connection has been established successfully.');
      } catch (error) {
        console.error('Unable to connect to the database:', error);
      }
})()

module.exports = sequelize;